/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-06-07 13:57:02
 * @LastEditTime : 2023-06-07 14:51:39
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Beam.jsx
 * @Description  :
 */

import { API_LIST } from '../../../Api/Api'
import { commonTableList, BuiltInData } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { BeamType } from '../Common/Conversion'

export const Beam = async ({ url, OptionsEvent, ClientData, Permission }) => {
    const beamTypeUuid = await BeamType()
    Permission = Permission.find(v => v.targetUrl === url).children
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}GetBeamsLists`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '328e587c-710e-4695-91d5-813ee4923095') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            {
                dataIndex: 'bridgeName',
                title: '桥名称',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'part',
                title: '部位',
                valueType: 'select',
                valueEnum: BuiltInData.part,
                width: 200,
            },
            {
                dataIndex: 'beamTypeUuid',
                title: '梁类别',
                valueType: 'select',
                valueEnum: beamTypeUuid,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'beamNo',
                title: '梁号',
                valueType: 'input',
                rules: true,
                hideInSearch: true,
                width: 200,
            },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '2ed93fb8-966c-4e12-82f8-1cd67a60f16b') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '184a8b7a-f518-4837-ab96-615e33dcaefb') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
